


function ThemeBox()
{
	this.init=function(uid,opener)
	{
		opener=opener==undefined?'skin':opener;
		_createbox(uid,opener);
		_bind();
	}

	var _createbox=function(uid,opener)
	{
		if($("#themebox_board_"+uid).length>0)
		{
			$("#themebox_board_"+uid).css('display','block').trigger('click');
			return false;
		}
		var uth=usr.getpro(uid,'theme');
		var usko=(parseInt(uth['skinopacity'])-30)*108/70;
		usko>110?usko=110:'';
		usko<4?usko=4:'';
		var uglo=(parseInt(uth['glassopacity'])-30)*108/70;
		uglo>110?uglo=110:'';
		uglo<4?uglo=4:'';
		var html=
		'<div class="themebox_board owner_'+uid+'" id="themebox_board_'+uid+'">'+
		'<div class="themebox_bar">'+
		'<div class="bar_color theme_color_'+uid+' theme_op_'+uid+'"></div>'+
		'<div class="bar_content">'+
		'<div class="themebox_barname"><img src="img/all_logo16-xp-2014.ico"/>更改外观</div>'+
		'<div class="themebox_close"></div>'+
		'<div class="clear"></div>'+
		'</div></div>'+
		'<div class="themebox_title">'+
		'<div class="themebox_title_tag skin_tag'+(opener=='skin'?' selected':'')+'"><div class="tag_ico"></div>皮肤设置</div>'+
		'<div class="themebox_title_tag sceneshow_tag'+(opener=='scene'?' selected':'')+'"><div class="tag_ico"></div>场景秀</div>'+
		'<div class="themebox_title_tag bubble_tag'+(opener=='bubble'?' selected':'')+'"><div class="tag_ico"></div>多彩气泡</div>'+
		'<div class="themebox_title_tag ui_tag'+(opener=='ui'?' selected':'')+'"><div class="tag_ico"></div>界面管理</div>'+
		'<div class="moreset"></div>'+
		'<div class="clear"></div>'+
		'</div>'+
		'<div class="themebox_content open_'+opener+'">'+
		'<!--皮肤设置面板-->'+
		'<div class="themebox_detail_skin themebox_detail">'+

		'<div class="themebox_skinselect">'+
		'<div class="themebox_picskin">'+
		'<table cellspacing="0" cellpadding="0">'+
		'<tr>'+
		'<td tid="">'+
		'</td>'+
		'<td tid="">'+
		'</td>'+
		'<td tid="">'+
		'</td>'+
		'<td tid="">'+
		'</td>'+
		'<td tid="">'+
		'</td>'+
		'<td tid="">'+
		'</td>'+
		'</tr>'+
		'<tr>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'</tr>'+
		'<tr>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'<td tid=""> </td>'+
		'</tr>'+
		'</table>'+
		'</div>'+
		'<div class="themebox_colorskin">'+
		'<table cellspacing="0" cellpadding="0">'+
		'<tr>'+
		'<td color="#3399CC" style="background:#3399CC;"> </td>'+
		'<td color="#0066CC" style="background:#0066CC;"> </td>'+
		'<td color="#009966" style="background:#009966;"> </td>'+
		'<td color="#FF6666" style="background:#FF6666;"> </td>'+
		'<td color="#FF99CC" style="background:#FF99CC;"> </td>'+
		'<td color="#CC3366" style="background:#CC3366;"> </td>'+
		'<td color="#663399" style="background:#663399;"> </td>'+
		'<td color="#666699" style="background:#666699;"> </td>'+
		'<td color="#006699" style="background:#006699;"> </td>'+
		'<td color="#009999" style="background:#009999;"> </td>'+
		'<td color="#009966" style="background:#009966;"> </td>'+
		'<td color="#339999" style="background:#339999;"> </td>'+
		'<td color="#99CCFF" style="background:#99CCFF;"> </td>'+
		'<td color="#ABCDEF" style="background:#ABCDEF;"> </td>'+
		'<td color="#993333" style="background:#993333;"> </td>'+
		'<td color="#FFCC33" style="background:#FFCC33;"> </td>'+
		'<td color="#CCCC99" style="background:#CCCC99;"> </td>'+
		'<td class="diycolor"></td>'+
		'</tr>'+
		'</table>'+
		'</div>'+
		'</div>'+
		
		'<div class="themebox_skinbtnbox">'+
		'<div class="sevenskin skinbtn">7天皮肤套装</div>'+
		'<div class="diyskin skinbtn"><img src="img/skinmgr/2012/plus.png"/>自定义<input type="file" name="theme_diypic" class="theme_diypic"/></div>'+
		'<div class="moreskin skinbtn">更多皮肤</div>'+
		'<div class="glassset adjustframe '+(parseInt(uth['openglass'])>0?'':'disable')+'" title="开启毛玻璃效果">'+
		'<div class="adjustbar skoadjust">'+
		'<div class="adjustbarblock glasssetblock" style="top:'+usko+'px;"></div>'+
		'</div>'+
		'</div>'+
		'<div class="opacityset adjustframe" title="设置全透明皮肤">'+
		'<div class="adjustbar gloadjust">'+
		'<div class="adjustbarblock opacitysetblock" style="top:'+uglo+'px;"></div>'+
		'</div>'+
		'</div>'+
		'<div class="clear"></div>'+
		'</div>'+
		'</div><!--皮肤设置面板-->'+
		'<!---场景秀面板--->'+
		'<div class="themebox_detail_sceneshow themebox_detail">'+
		'<div class="themebox_sceneselect">'+
		'<div class="themebox_sceneselectcnt">'+
		'<div class="themebox_sceneselectpage">'+
		'<div class="scenebox">'+
		'<div class="scenebox_title">精彩推荐</div>'+
		'<table class="scenebox_cnt scene_recommend"  cellspacing="0" cellpadding="0">'+
		/*
		'<tr>'+
		'<td tid="">'+
		'<div class="pic">'+
		'<img src="img/back2.jpg"/>'+
		'<div class="skintag isvip"></div>'+
		'</div>'+
		'<div class="blackglass"></div>'+
		'<div class="picinfo">'+
		'<p class="infoname">埃及金字塔</p>'+
		'<p class="using">105115151人使用</p>'+
		'</div>'+
		'</td>'+
		'<td tid=""></td>'+
		'<td tid=""></td>'+
		'<td tid=""></td>'+
		'</tr>'+
		*/
		'</table>'+
		
		'<div class="scenebox_title">热门场景</div>'+
		'<table class="scenebox_cnt scene_hot"  cellspacing="0" cellpadding="0">'+
		/*
		'<tr>'+
		'<td tid="">'+
		'<div class="pic">'+
		'<img src="img/back2.jpg"/>'+
		'<div class="skintag isvip"></div>'+
		'</div>'+
		'<div class="blackglass"></div>'+
		'<div class="picinfo">'+
		'<p class="infoname">埃及金字塔</p>'+
		'<p class="using">105115151人使用</p>'+
		'</div>'+
		'</td>'+
		'<td tid=""></td>'+
		'<td tid=""></td>'+
		'<td tid=""></td>'+
		'</tr>'+
		*/
		'</table>'+
		
		'</div>'+
		'</div>'+
		'</div>'+
		'</div>'+
		'<div class="themebox_scenebtnbar">'+
		'<div class="switchbox themebox_scenesex">'+
		'<div class="switchleft switchbtn selected">男套装</div>'+
		'<div class="switchright switchbtn">女套装</div>'+
		'<div class="clear"></div>'+
		'</div>'+
		'<div class="scenebtn">更多场景秀</div>'+
		'<a target="_blank" href="#">开通VIP会员可以免费使用全部场景秀</a>'+
		'</div>'+
		'</div><!---场景秀面板--->'+
		'<!---多彩气泡页mod_bubble气泡/mod_text文本两种模式--->'+
		'<div class="themebox_detail_bubble themebox_detail '+(parseInt(uth['chatmode'])>0?'mod_bubble':'mod_text')+'">'+
		'<!--气泡模式时显示的选择框-->'+
		'<div class="themebox_bubbleselect">'+
		'<div class="themebox_bubbleselectcnt">'+
		'<div class="themebox_bubbleselectpage">'+
		'<table class="bubblebox_cnt"  cellspacing="0" cellpadding="0">'+
		'<tr>'+
		'<td tid="">'+
		'<div class="pic">'+
		'<img src="img/back2.jpg"/>'+
		'</div>'+
		'<div class="blackglass"></div>'+
		'<div class="picinfo">'+
		'<p class="infoname">埃及金字塔</p>'+
		'</div>'+
		'<div class="viptag"></div>'+
		'</td>'+
		'<td tid=""></td>'+
		'<td tid=""></td>'+
		'<td tid=""></td>'+
		'</tr>'+
		'</table>'+
		'</div>'+
		'</div>'+
		'</div>'+
		'<!--文本模式时提示文本-->'+
		'<div class="themebox_nonbubbletips"></div>'+
		'<!--按钮bar-->'+
		'<div class="themebox_bubblebtnbar">'+
		'<div class="switchbox themebox_selectbubbleortext">'+
		'<div class="switchleft switchbtn '+(parseInt(uth['chatmode'])>0?'selected':'')+'">气泡模式</div>'+
		'<div class="switchright switchbtn '+(parseInt(uth['chatmode'])>0?'':'selected')+'">文本模式</div>'+
		'<div class="clear"></div>'+
		'</div>'+
		'<p class="nonbubbletips">你的好友仍可显示你当前设置的气泡</p>'+
		'<a target="_blank" href="#" class="bubblebtn">开通会员</a>'+
		'<p>QQ会员尊享全部VIP气泡</p>'+
		'<div class="clear"></div>'+
		'</div>'+
		'</div><!---多彩气泡页--->'+
		'<!--界面管理页-->'+
		'<div class="themebox_detail_ui themebox_detail">'+
		'<div class="themebox_uibox">'+
		'<div class="mainboardset themebox_setboard">'+
		'<div class="themebox_settitle">显示在主面板</div>'+
		'<div class="themebox_setcnt">'+
		'<ul>'+
		'<li><div class="ck checked disable"></div><div class="ico"><img src="img/mainpanel/icon_contacts_selected_Blue.png"/></div>联系人</li>'+
		'<li><div class="ck checked disable"></div><div class="ico"><img src="img/mainpanel/icon_group_selected_Blue.png"/></div>群/讨论组</li>'+
		'<li><div class="ck checked disable"></div><div class="ico"><img src="img/mainpanel/icon_last_selected_Blue.png"/></div>会话</li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/mainpanel/weather_icon_Blue.png"/></div>天气</li>'+
		'</ul>'+
		'</div>'+
		'</div>'+
		'<div class="myinfoset themebox_setboard">'+
		'<div class="themebox_settitle">显示在个人信息区'+
		'<div class="todown movebtn"><img src="img/mainpanel/panelcenter/downbtn.png"/>下移</div>'+
		'<div class="toup movebtn disable"><img src="img/mainpanel/panelcenter/upbtn.png"/>上移</div>'+
		'</div>'+
		'<div class="themebox_setcnt theme_color_'+uid+'">'+
		'<ul>'+
		'<li class="selected"><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/16.png"/></div>QQ空间</li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/TencentNet.png"/></div>腾讯网迷你版</li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/35/icon.png"/></div>我的邮箱</li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/244/icon.png"/></div></li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/185/icon.png"/></div></li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/"/></div></li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/"/></div></li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/VasBizIcon/"/></div></li>'+
		'<li><div class="ck checked"></div><div class="ico"><img src="img/mainpanel/panelcenter/areamainicon.png"/></div>界面管理器</li>'+
		'</ul>'+
		'</div>'+
		'</div>'+
		'</div>'+
		'</div><!--界面管理页-->'+
		'</div>'+
		/*
		'<div class="themebox_subwindow themebox_setbox">'+
		'<div class="themebox_subwindowbar">'+
		'<div class="bar_color theme_color_'+uid+'"></div>'+
		'<div class="bar_content">'+
		'<div class="themebox_barname"><img src="img/all_logo16-xp-2014.ico"/>设置</div>'+
		'<div class="themebox_subwindowclose"></div>'+
		'<div class="clear"></div>'+
		'</div>'+
		'</div>'+
		'<div class="themebox_subwindowcnt">'+
		'<ul>'+
		'<li class="showmyskin"><div class="ck"></div>向好友展示我的皮肤</li>'+
		'<li class="usemyskin"><div class="ck"></div>默认显示自己的皮肤和QQ秀</li>'+
		'<li class="covermode"><div class="ck disable"></div>主面板使用"封面"模式</li>'+
		'</ul>'+
		'</div>'+
		'<div class="themebox_subwindowfoot theme_color_'+uid+'">'+
		'<div class="themebox_subwindowfootglass"></div>'+
		'<div class="themebox_subwindowfootcnt">'+
		'<div class="themebox_subwindowbutton themebox_subcancel">取消</div>'+
		'<div class="themebox_subwindowbutton themebox_subconfirm">确定</div>'+
		'<div class="clear"></div>'+
		'</div>'+
		'</div>'+
		'</div>'+
		*/
		'</div>';


		$('body').append(html);
		var winY=window.innerHeight||document.body.clientHeight;
		var winX=window.innerWidth||document.body.clientWidth;
		winY=((winY-541)/2)-50;
		winY=winY<=0?10:winY;
		winX=(winX-748)/2;
		$('#themebox_board_'+uid).css('top',winY+'px').css('left',winX+'px');

		//设置顶部bar色
		var th=usr.getpro(uid,'theme');
		$('#themebox_board_'+uid+' .theme_color_'+uid).css('background',th['bgcolor']);
		$('#themebox_board_'+uid+' .theme_op_'+uid).css("filter","alpha(opacity="+th['skinopacity']+")").css("-moz-opacity",(th['skinopacity']/100)).css("opacity",(th['skinopacity']/100));

		setload(uid,opener);

	}
	
	function setload(uid,opener)
	{
		if($('#themebox_board_'+uid+' .themebox_detail_'+opener).attr('load')=="true")
		{
			return;
		}
		if(opener=='skin')
		{
			ajax('m=getall','setTheme.php',function(m)
			{
				
				if(m)
				{
					var td=$('#themebox_board_'+uid+' .themebox_skinselect .themebox_picskin td');
					
					for(var i=0;i<td.length;i++)
					{
						td.eq(i).html(
						'<div class="pic">'+
						'<img src="'+m[i].bgimg+'"/>'+
						'<div class="skintag '+(m[i].vip==1?'isvip':'')+(m[i]['new']==1?'today':'')+'"></div>'+
						'</div>'+
						'<div class="blackglass"></div>'+
						'<a class="picinfo" tid="'+m[i].id+'" uid="'+uid+'" co="'+m[i].coloronly+'" bgcolor="'+m[i].bgcolor+'" og="'+m[i].openglass+'" sko="'+m[i].skinopacity+'" glo="'+m[i].glassopacity+'" bgimg="'+m[i].bgimg+'" isvip="'+m[i].vip+'" href="javascript:;" onClick="setskin(this)">'+
						'<p class="infoname">'+m[i].name+'</p>'+
						'<p class="using">'+m[i].usernum+'人使用</p>'+
						'<div class="picbottom">'+
						'<div class="offer"><img src="img/skinmgr/2012/style.png"/>QQ装扮提供</div>'+
						'<div class="share"></div>'+
						'</div>'+
						'</a>')/*.attr('tid',m[i].id)*/;
					}
				}
			});

		}
		else if(opener=="sceneshow")
		{
			
			ajax('m=getscene','setTheme.php',function(m)
			{
				if(m)
				{
					
					if(m.recommend)
					{
						console.log(m.recommend);
						var html='<tr>';
						for(var i=0,flag=0;i<m.recommend.length;i++)
						{
							html+=
							'<td tid="'+m.recommend[i].id+'">'+
							'<div class="pic">'+
							'<img src="'+m.recommend[i].img+'"/>'+
							'<div class="skintag isvip"></div>'+
							'</div>'+
							'<div class="blackglass"></div>'+
							'<div class="picinfo">'+
							'<p class="infoname">'+m.recommend[i].name+'</p>'+
							'<p class="using">'+m.recommend[i].usernum+'人使用</p>'+
							'</div>'+
							'</td>';
							flag+=1;
							if(i==(m.recommend.length-1))
							{
								for(var k=0;k<4-flag;k++)
								{
									html+="<td></td>";
								}
								break;
							}
							
							
							if(i%3==0&&i>0)
							{
								html+='</tr><tr>';
								flag=0;
							}
							
						}
						html+='</tr>';

						$("#themebox_board_"+uid+" .scene_recommend").html(html);
					}
					
					if(m.hot)
					{
						var html='<tr>';
						for(var i=0,flag=0;i<m.hot.length;i++)
						{
							html+=
							'<td tid="'+m.hot[i].id+'">'+
							'<div class="pic">'+
							'<img src="'+m.hot[i].img+'"/>'+
							'<div class="skintag isvip"></div>'+
							'</div>'+
							'<div class="blackglass"></div>'+
							'<div class="picinfo">'+
							'<p class="infoname">'+m.hot[i].name+'</p>'+
							'<p class="using">'+m.hot[i].usernum+'人使用</p>'+
							'</div>'+
							'</td>';
							flag+=1;
							if(i==(m.hot.length-1))
							{
								for(var k=0;k<4-flag;k++)
								{
									html+="<td></td>";
								}
								break;
							}
							
							
							if(i%3==0&&i>0)
							{
								html+='</tr><tr>';
								flag=0;
							}
							
						}
						html+='</tr>';

						$("#themebox_board_"+uid+" .scene_hot").html(html);
						
					}
				}
			});
			
		}
		else if(opener=="bubble")
		{
			//文本模式的话不需要加载
			if($("#themebox_board_"+uid+" .mod_text").length>0)
			{
				return;
			}
			ajax('m=getbubble','setTheme.php',function(m)
			{
				if(m)
				{
					var html='<tr>';
					for(var i=0,flag=0;i<m.length;i++)
					{
						html+=
						'<td tid="'+m[i].id+'">'+
						'<div class="pic">'+
						'<img src="'+m[i].bubble_viewimg+'"/>'+
						'<div class="blackglass"></div>'+
						'<div class="picinfo" bg="'+m[i].bubble_img+'" obg="'+m[i].bubble_imgshow+'" bgimg="'+m[i].bubble_bgimg+'">'+
						'<p class="infoname">'+m[i].bubble_name+'</p>'+
						'</div>'+
						'<div class="viptag '+(m[i].vip==1?'isavip':'')+'"></div>'+
						'</td>';

						flag+=1
						if(i==(m.length-1))
						{
							for(var k=0;k<4-flag;k++)
							{
								html+="<td></td>";
							}
							break;
						}
						
						
						if(i%3==0&&i>0)
						{
							html+='</tr><tr>';
							flag=0;
						}
						
					}
					html+='</tr>';

					$("#themebox_board_"+uid+" .bubblebox_cnt").html(html);
					
				}
			});

			
		}
		else if(opener=="ui")
		{
			
			var detail=$("#themebox_board_"+uid+" .themebox_detail_"+opener);
			var load=detail.find('.loadingboard');
			if(load.length<=0)
			{
				return;
			}
		}

		$('#themebox_board_'+uid+' .themebox_detail_'+opener).attr('load','true');
	}

	
	function ajax(data,url,sfunc,efunc)
	{
		$.ajax({
			url:'action/'+url,
			data:data,
			dataType:'json',
			method:'POST',
			success:function(m)
			{
				sfunc(m);
			},
			error:function()
			{
				(typeof efunc=="function")?efunc():'';
			}
			
		});

	}




	var _bind=function()
	{
		var bar=$(".themebox_bar");
		drag(bar,bar.parent(".themebox_board"),'',function(o)
		{
			//console.log(o);
		});
		$('.themebox_close').click(function()
		{
			$(this).parents('.themebox_board').remove();
		});
		
		//切换页
		$('.themebox_title_tag').click(function()
		{
			var tagname='';
			if($(this).hasClass('selected'))
			{
				return;
			}
			var uid=$(this).parents('.themebox_board').attr('id').replace('themebox_board_','');
			if($(this).hasClass('skin_tag'))
			{
				tagname='skin';
			}
			else if($(this).hasClass('sceneshow_tag'))
			{
				tagname='sceneshow';
			}
			else if($(this).hasClass('bubble_tag'))
			{
				tagname='bubble';
			}
			else if($(this).hasClass('ui_tag'))
			{
				tagname='ui';
			}
			$(this).siblings('.selected').removeClass('selected');
			$(this).addClass('selected');
			$(this).parent('.themebox_title').siblings('.themebox_content').attr('class','themebox_content open_'+tagname);
			setload(uid,tagname);
		});

		//气泡模式/文本模式切换
		$('.switchbtn').click(function()
		{
			if($(this).hasClass('selected'))
			{
				return;
			}
			var uid=$(this).parents('.themebox_board').attr('id').replace('themebox_board_','');
			var uth=usr.getpro(uid,'theme');
			if($(this).parent('.switchbox').hasClass('themebox_selectbubbleortext'))
			{
				var mode=0;
				if($(this).hasClass("switchleft"))
				{
					$(this).parents('.themebox_detail_bubble').removeClass('mod_text').addClass('mod_bubble');
					var uid=$(this).parents('.themebox_board').attr('id').replace('themebox_board_','');
					setload(uid,'bubble');
					mode=1;
				}
				else if($(this).hasClass("switchright"))
				{
					$(this).parents('.themebox_detail_bubble').removeClass('mod_bubble').addClass('mod_text');
					mode=0;
				}
				//这里设置到全局数组中
				
				$.ajax({
					url:'action/settheme.php',
					data:"u="+uid+"&&m=setpro&&d=chatmode:"+mode,
					dataType:'json',
					method:'POST',
					success:function(m)
					{
						if(m)
						{
							//设置到数组中
							uth['chatmode']=mode;
							usr.setpro(uid,'theme',uth);
							//设置到所有聊天界面中
							mode>0?$('.owner_'+uid+' .chatbox_msgtype').removeClass('msg_list').addClass('msg_bubble'):$('.owner_'+uid+' .chatbox_msgtype').removeClass('msg_bubble').addClass('msg_list');

							console.log('气泡/文本模式切换成功');
						}
						else
						{
							console.log('气泡/文本模式切换失败');
						}
				
					},
					error:function()
					{
						console.log('气泡/文本模式切换失败，网络异常');
					}
					
				});
			}
			else if($(this).parent('.switchbox').hasClass('themebox_scenesex'))
			{

			}
			$(this).siblings('.selected').removeClass('selected');
			$(this).addClass('selected');
		});

		//打开主题设置盒
		$('.themebox_title .moreset').click(function(e)
		{
			var uid=$(this).parents('.themebox_board').attr('id').replace('themebox_board_','');
			if($('#themebox_setbox_'+uid).length>0)
			{
				$('#themebox_setbox_'+uid).css('display','block');
				return false;
			}
			var set=usr.getpro(uid,'setting');
			$('body').append(
			'<div class="themebox_subwindow themebox_setbox" id="themebox_setbox_'+uid+'">'+
			'<div class="themebox_subwindowbar">'+
			'<div class="bar_color theme_color_'+uid+' theme_op_'+uid+'"></div>'+
			'<div class="bar_content">'+
			'<div class="themebox_barname"><img src="img/all_logo16-xp-2014.ico"/>设置</div>'+
			'<div class="themebox_subwindowclose"></div>'+
			'<div class="clear"></div>'+
			'</div>'+
			'</div>'+
			'<div class="themebox_subwindowcnt">'+
			'<ul>'+
			'<li class="showmyskin"><div class="ck '+(parseInt(set['chatframe_showmyskin'])>0?'checked':'')+'"></div>向好友展示我的皮肤</li>'+
			'<li class="usemyskin"><div class="ck '+(parseInt(set['chatframe_usemyskin'])>0?'checked':'')+'"></div>默认显示自己的皮肤和QQ秀</li>'+
			'<li class="covermode"><div class="ck disable"></div>主面板使用"封面"模式</li>'+
			'</ul>'+
			'</div>'+
			'<div class="themebox_subwindowfoot">'+
			'<div class="themebox_subwindowfootcolor theme_color_'+uid+'"></div>'+
			'<div class="themebox_subwindowfootglass"></div>'+
			'<div class="themebox_subwindowfootcnt">'+
			'<div class="themebox_subwindowbutton themebox_subcancel">取消</div>'+
			'<div class="themebox_subwindowbutton themebox_subconfirm">确定</div>'+
			'<div class="clear"></div>'+
			'</div>'+
			'</div>'+
			'</div>'
			);
			//设置顶部bar色
			var th=usr.getpro(uid,'theme');
			$('#themebox_setbox_'+uid+' .theme_color_'+uid).css('background',th['bgcolor']);
			$('#themebox_setbox_'+uid+' .theme_op_'+uid).css("filter","alpha(opacity="+th['skinopacity']+")").css("-moz-opacity",(th['skinopacity']/100)).css("opacity",(th['skinopacity']/100));

			var tb=$('#themebox_board_'+uid);
			tb.append('<div class="dispalyboard"></div>');
			
			var l=tb[0].offsetLeft+((748-326)/2);
			var t=tb[0].offsetTop+((541-158)/2);
	
			console.log(tb[0].offsetLeft+','+tb[0].offsetTop);
			console.log(l+','+t);
			$('#themebox_setbox_'+uid).css('top',t+'px').css('left',l+'px');

			drag($('.themebox_setbox'));
			$('.dispalyboard').click(function()
			{
				$("#goading")[0].play();
			});
	
			//主题盒子设置事件绑定
			$('.themebox_subwindowclose').click(function()
			{
				var uid=$(this).parents('.themebox_setbox').attr('id').replace('themebox_setbox_','');
				$('#themebox_board_'+uid+' .dispalyboard').remove();
				$(this).parents('.themebox_subwindow').remove();
			});
			$('.themebox_subcancel').click(function()
			{
				var uid=$(this).parents('.themebox_setbox').attr('id').replace('themebox_setbox_','');
				$('#themebox_board_'+uid+' .dispalyboard').remove();
				$(this).parents('.themebox_subwindow').remove();
			});

			$('.themebox_subconfirm').click(function()
			{
				var uid=$(this).parents('.themebox_setbox').attr('id').replace('themebox_setbox_','');
				$('#themebox_board_'+uid+' .dispalyboard').remove();
				$(this).parents('.themebox_subwindow').remove();
			});
		});
		
		

		//---皮肤设置------------------------------------------
		/*$('.themebox_skinbtnbox .diyskin').click(function(e)
		{
			$(this).find('.theme_diypic').trigger('click');
		});
		*/
		$('.theme_diypic').change(function(e)
		{

		});

		//点击更改皮肤颜色
		$(".themebox_colorskin td").click(function(e)
		{
			var uid=$(this).parents('.themebox_board').attr('id').replace('themebox_board_','');
			
			var color=$(this).attr('color');

			$.ajax({
				url:'action/settheme.php',
				data:"u="+uid+"&&m=setcolor&&c="+color,
				dataType:'json',
				method:'POST',
				success:function(m)
				{
					//设置到数组中
					var th=usr.getpro(uid,'theme');
					th['bgcolor']=color;
					th['bgimg']="";
					th['skinopacity']=100;
					th['glassopacity']=100;
					usr.setpro(uid,'theme',th);
					//设置到界面中
					//console.log(th);
					//总体颜色
					$(".theme_color_"+uid).css('background',color);
					$(".theme_op_"+uid).css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);
					$("#mainboard_"+uid+" .mainboardcolor").css('background',color).css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);
					//主面板颜色覆盖度
					$("#mainboard_"+uid+" .mainboardglass").css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);

					$('#themebox_board_'+uid+' .glassset').hasClass('disable')?'':$('#themebox_board_'+uid+' .glassset').addClass('disable');
				
					$('#themebox_board_'+uid+' .glasssetblock').css('top','110px');
					$('#themebox_board_'+uid+' .opacitysetblock').css('top','110px');
				},
				error:function()
				{
					console.log('网络不好');
				}
				
			});

		});

		//皮肤颜色覆盖度及整体透明度调节条上的滑动调节块
		drag($('.glasssetblock'),'',{y:true,mintop:4,maxtop:110},function(o)
		{
			var t=$(o.obj);
			var af=t.parents('.adjustframe');
			var uid=t.parents('.themebox_board').attr('id').replace('themebox_board_','');

			if(af.hasClass('disable')||parseInt(usr.getpro(uid,'theme')['openglass'])==0)
			{
				return false;
			}
			var offset=Math.round((o.top*70)/108);
			offset>70?offset=70:'';
			offset-=offset%5;
			offset+=30;
			/*
			if(af.hasClass('glassset'))
			{
			*/
				//设置整体透明度（根据是否开启毛玻璃效果）
				$("#mainboard_"+uid+" .mainboardcolor").css("filter","alpha(opacity="+offset+")").css("-moz-opacity",(offset/100)).css("opacity",(offset/100));
				$(".theme_op_"+uid).css("filter","alpha(opacity="+offset+")").css("-moz-opacity",(offset/100)).css("opacity",(offset/100));
				tempval.setone(uid,'theme','sko',offset);
			/*
			}
			else if(af.hasClass('opacityset'))
			{
				//主面板颜色覆盖度
				$("#mainboard_"+uid+" .mainboardglass").css("filter","alpha(opacity="+offset+")").css("-moz-opacity",(offset/100)).css("opacity",(offset/100));
				tempval.setone(uid,'theme','glo',offset);
			}
			return;
			*/
		});
		drag($('.opacitysetblock'),'',{y:true,mintop:4,maxtop:110},function(o)
		{
			var t=$(o.obj);
			var uid=t.parents('.themebox_board').attr('id').replace('themebox_board_','');

			var offset=Math.round((o.top*70)/108);
			offset>70?offset=70:'';
			offset-=offset%5;
			offset+=30;
			
			//主面板颜色覆盖度
			$("#mainboard_"+uid+" .mainboardglass").css("filter","alpha(opacity="+offset+")").css("-moz-opacity",(offset/100)).css("opacity",(offset/100));
			tempval.setone(uid,'theme','glo',offset);
	
		});

		



		//点击开启毛玻璃效果
		$('.themebox_skinbtnbox .glassset').click(function(e)
		{
			var t=$(this);
		
			if($(e.target).hasClass('adjustbarblock'))
			{
				return false;
			}
			var uid=t.parents('.themebox_board').attr('id').replace('themebox_board_','');
			
			if(t.hasClass('disable'))
			{
				//开启毛玻璃
				var sko=usr.getpro(uid,'theme')['skinopacity'];
				//设置整体透明度（根据是否开启毛玻璃效果）
				$("#mainboard_"+uid+" .mainboardcolor").css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
				$(".theme_op_"+uid).css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
				t.removeClass('disable');
				tempval.setone(uid,'theme','og',1);
			}
			else
			{
				//关闭毛玻璃
				$("#mainboard_"+uid+" .mainboardcolor").css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);
				$(".theme_op_"+uid).css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);
				t.addClass('disable');
				tempval.setone(uid,'theme','og',0);
			}
			e.stopImmediatePropagation();

			
		}).mouseout(function(e)
		{
			var uid=$(this).parents('.themebox_board').attr('id').replace('themebox_board_','');
			//鼠标移出调节器时，如果临时变量中有值，则比较全局变量中的值，如果有变动，则更新到全局变量和服务器中
			ajaxpro(uid);
			e.stopImmediatePropagation();
		});
		
		//设置整体颜色覆盖度
		$('.themebox_skinbtnbox .opacityset').mouseout(function(e)
		{
			var uid=$(this).parents('.themebox_board').attr('id').replace('themebox_board_','');
			//鼠标移出调节器时，如果临时变量中有值，则比较全局变量中的值，如果有变动，则更新到全局变量和服务器中
			ajaxpro(uid);
			e.stopImmediatePropagation();
		});



	}




}
function ajaxpro(uid)
{
	var temp=tempval.getoneall(uid,'theme');
	if(temp===false||temp.length<=0)
	{
		console.log('临时数组没有收到修改内容');
		return false;
	}
	var th=usr.getpro(uid,'theme');
	if(th===false)
	{
		console.log('用户主题数组为空');
		return false;
	}
	var str='';

	var sko=temp['sko'];

	if(sko!==false&&sko!=undefined&&sko!=parseInt(th['skinopacity']))
	{
		str+='skinopacity:'+sko+',';
		th['skinopacity']=sko;
	}

	var glo=temp['glo'];

	if(glo!==false&&glo!=undefined&&glo!=parseInt(th['glassopacity']))
	{
		str+='glassopacity:'+glo+',';
		th['glassopacity']=glo;
	}

	var og=temp['og'];

	if(og!==false&&og!=undefined&&og!=parseInt(th['openglass']))
	{
		str+='openglass:'+og;
		th['openglass']=og;
	}
	if(str==undefined||str=="")
	{
		console.log('没有设置，返回');
		return;
	}

	if(str[str.length-1]==",")
	{
		str=str.substring(0,str.length-1);
	}
	
	//设置到数组中
	usr.setpro(uid,'theme',th);
				
	//清空临时数组
	tempval.cleanoneall(uid,'theme');
	
	$.ajax({
		url:'action/settheme.php',
		data:"u="+uid+"&&m=setpro&&d="+str,
		dataType:'json',
		method:'POST',
		success:function(m)
		{
			if(m)
			{
				//设置到数组中
				console.log('调节器设置成功');
				//console.log(th);
				//console.log(usr.getpro(uid,'theme'));
			}
			else
			{
				console.log('设置调节器出错，无法更新到服务器');
				/*
				var th=usr.getpro(uid,'theme');
				var bgcolor=th['bgcolor'];
				var bgimg=th['bgimg'];
				var sko=th['skinopacity'];
				var glo=th['glassopacity'];
				var og=th['openglass'];
				//设置到界面中
				//总体颜色
				$(".theme_color_"+uid).css('background',bgcolor);
				$(".theme_op_"+uid).css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);
				bgimg!=""&&bgimg!=undefined?$(".theme_bgimg_"+uid).css('background','url('+bgimg+')').css('background-size','cover'):'';

				//主面板颜色覆盖度
				$("#mainboard_"+uid+" .mainboardglass").css("filter","alpha(opacity="+glo+")").css("-moz-opacity",(glo/100)).css("opacity",(glo/100));
				
				//设置整体透明度（根据是否开启毛玻璃效果）
				if(og)
				{
					$("#mainboard_"+uid+" .mainboardcolor").css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
					$(".theme_op_"+uid).css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
				}
				*/
			}
	
		},
		error:function()
		{
			console.log('网络不好');
			/*
			var th=usr.getpro(uid,'theme');
			var bgcolor=th['bgcolor'];
			var bgimg=th['bgimg'];
			var sko=th['skinopacity'];
			var glo=th['glassopacity'];
			var og=th['openglass'];
			//设置到界面中
			//总体颜色
			$(".theme_color_"+uid).css('background',bgcolor);
			$(".theme_op_"+uid).css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);
			bgimg!=""&&bgimg!=undefined?$(".theme_bgimg_"+uid).css('background','url('+bgimg+')').css('background-size','cover'):'';

			//主面板颜色覆盖度
			$("#mainboard_"+uid+" .mainboardglass").css("filter","alpha(opacity="+glo+")").css("-moz-opacity",(glo/100)).css("opacity",(glo/100));
			
			//设置整体透明度（根据是否开启毛玻璃效果）
			if(og)
			{
				$("#mainboard_"+uid+" .mainboardcolor").css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
				$(".theme_op_"+uid).css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
			}
			*/
		}
		
	});
}





function setskin(o)
{
	var o=$(o);
	//{uid:"'+uid+'",id:"'+m[i].id+'",isvip:"'+m[i].vip+'",bgcolor:"'+m[i].bgcolor+'",bgimg:"'+m[i].bgimg+'",sko:"'+m[i].skinopacity+'",glo:"'+m[i].glassopacity+'"}
	//console.log(o);

	var uid=o.attr('uid');
			
	var tid=o.attr('tid');
	var bgcolor=o.attr('bgcolor');
	//console.log('bgcolor='+bgcolor);
	var sko=parseInt(o.attr('sko'));
	var bgimg=o.attr('bgimg');
	//console.log('bgimg='+bgimg);
	var glo=parseInt(o.attr('glo'));
	var isvip=o.attr('isvip');
	var og=parseInt(o.attr('og'));
	var coloronly=parseInt(o.attr('co'));
	//console.log(usr.getuser(uid));
	if(parseInt(usr.getuser(uid).isvip)<parseInt(isvip))
	{
		console.log('您不是会员');
		return false;
	}
	//console.log(usr.getpro(uid,'theme'));

	
	
	$.ajax({
			url:'action/settheme.php',
			data:"u="+uid+"&&m=setskin&&t="+tid,
			dataType:'json',
			method:'POST',
			success:function(m)
			{
				//设置到数组中
				var th=usr.getpro(uid,'theme');
				th['bgcolor']=bgcolor;
				th['bgimg']=bgimg;
				th['skinopacity']=sko;
				th['glassopacity']=glo;
				th['openglass']=og;
				usr.setpro(uid,'theme',th);
				//设置到界面中
				//console.log(th);
				//总体颜色
				$(".theme_color_"+uid).css('background',bgcolor);
				$(".theme_op_"+uid).css("filter","alpha(opacity=100)").css("-moz-opacity",1).css("opacity",1);
				coloronly==0?$(".theme_bgimg_"+uid).css('background','url('+bgimg+')').css('background-size','cover'):'';

				//主面板颜色覆盖度
				$("#mainboard_"+uid+" .mainboardglass").css("filter","alpha(opacity="+glo+")").css("-moz-opacity",(glo/100)).css("opacity",(glo/100));
				
				//设置整体透明度（根据是否开启毛玻璃效果）
				if(og)
				{
					$("#mainboard_"+uid+" .mainboardcolor").css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
					$(".theme_op_"+uid).css("filter","alpha(opacity="+sko+")").css("-moz-opacity",(sko/100)).css("opacity",(sko/100));
					$('#themebox_board_'+uid+' .glassset').removeClass('disable');
				}
				else
				{
					$('#themebox_board_'+uid+' .glassset').hasClass('disable')?'':$('#themebox_board_'+uid+' .glassset').addClass('disable');
				}

				var usko=(sko-30)*108/70;
				usko>110?usko=110:'';
				usko<4?usko=4:'';
				var uglo=(glo-30)*108/70;
				uglo>110?uglo=110:'';
				uglo<4?uglo=4:'';

				$('#themebox_board_'+uid+' .glasssetblock').css('top',usko+'px');
				$('#themebox_board_'+uid+' .opacitysetblock').css('top',uglo+'px');

				

			},
			error:function()
			{
				console.log('网络不好');
			}
			
		});

	

}